//
//  HYUserInfoApi.m
//  TJHYHardwareProduct
//
//  Created by JianWei Chen on 2018/1/23.
//  Copyright © 2018年 Kendama. All rights reserved.
//

#import "HYUserInfoApi.h"

@implementation HYUserInfoApi{
    NSDictionary *_dic;
}

-(id)initWithDic:(NSDictionary *)dic{
    if (self = [super init]) {
        _dic = dic;
    }
    return self;
}

- (NSString *)requestUrl {
    return @"/user/my_count_info";
}

- (YTKRequestMethod)requestMethod {
    return YTKRequestMethodPOST;
}

- (id)requestArgument {
    NSMutableDictionary *dic = [NSMutableDictionary getPubdic];
    
    [dic setValuesForKeysWithDictionary:_dic];
    NSString *sign=[NSString getSign:dic];
    [dic setObject:sign forKey:@"sign"];
    return dic;
}


-(void)dealloc
{
    NSLog(@"%@ dealloc",[self class]);
}

+ (void)getUserInfo:(void (^)(HYUserInfoModel *))successBack fail:(void (^)(NSDictionary *))failBack
{
    HYUserInfoApi *api = [[HYUserInfoApi alloc]initWithDic:@{}];
    [api dtStartYTKRequestCompletionBlockWithSuccess:^(YTKBaseRequest * _Nonnull request) {
        NSDictionary *dic = request.responseObject;
        if (dic[@"data"] && [dic[@"data"] isKindOfClass:[NSDictionary class]]) {
            NSDictionary *dataDic = dic[@"data"];
            HYUserInfoModel *model = [[HYUserInfoModel alloc]init];
            [model setValuesForKeysWithDictionary:dataDic];
            if (successBack) {
                successBack(model);
            }
        }
    } failure:^(YTKBaseRequest * _Nonnull request) {
        if (failBack) {
            failBack(request.responseObject);
        }
    }];
}
@end
